import 'package:bordered_text/bordered_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

import 'KaL_Config.dart';

class DL_drawNumbersView extends StatelessWidget {
  DL_drawNumbersView({super.key, required this.data});
  Map data; //显示的数据
  @override
  Widget build(BuildContext context) {
    ///
    List<Widget> _balls = [];
    //
    List _numbers = data['balls'] ??
        [
          {'number': 'A', 'isRight': false, 'isNormal': true},
          {'number': 'A', 'isRight': false, 'isNormal': true},
          {'number': '1', 'isRight': false, 'isNormal': true},
          {'number': '2', 'isRight': false, 'isNormal': true},
          {'number': '3', 'isRight': false, 'isNormal': true},
          {'number': '4', 'isRight': false, 'isNormal': true},
          {'number': '5', 'isRight': false, 'isNormal': true},
          // {'number': '6', 'isRight': false, 'isNormal': true}
        ];
    var _prizeAmount = data['prizeAmount'] ?? '';
    String _title = data['title'] ?? '';

    //
    if (_prizeAmount.isNotEmpty) {
      _title = '$_title - $_prizeAmount INR';
    }

    //
    for (var element in _numbers) {
      bool isRightNum = element['isRight'];
      bool isNormalNum = element['isNormal'];
      String number = element['number'];
      if (!isNormalNum) {
        if (isRightNum) {
          _balls.add(numberStrokeText(number));
        } else {
          _balls.add(numberText(number));
          // _balls.add(numberStrokeText(number, color: Colors.red));
        }
      } else {
        _balls.add(numberStrokeText(number));
      }
    }

    //号码区域高度
    double viewH = _title.isNotEmpty ? 75 : 60;

    return Container(
      height: viewH,
      width: double.infinity,
      // padding: const EdgeInsets.only(left: 10, right: 10),
      // margin: const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
      decoration: BoxDecoration(
        color: HexColor('#eeeeee'),
        borderRadius: const BorderRadius.all(Radius.circular(8)),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          _title.isNotEmpty
              ? Text(
                  '$_title',
                  style: const TextStyle(
                      fontWeight: FontWeight.w400,
                      fontSize: 12,
                      color: Colors.black),
                )
              : const SizedBox(
                  height: 0,
                  width: 0,
                ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: _balls,
          ),
        ],
      ),
    );
  }

  Widget numberStrokeText(String number) {
    return BorderedText(
      strokeWidth: 5.0,
      strokeColor: KaL_Config.KaL_jackpottextColor_w,
      child: Text(
        number,
        style: TextStyle(
          color: KaL_Config.KaL_MainColor,
          fontSize: 30.0,
          fontWeight: FontWeight.w700,
        ),
      ),
    );
  }

  Widget numberText(String number) {
    return Text(
      number,
      style: TextStyle(
        color: HexColor('#999999'),
        fontSize: 30.0,
        fontWeight: FontWeight.w700,
      ),
    );
  }
}
